--- Model of Java names.
module frege.compiler.types.JNames where 

--- A Java name
--- The 'JName.qual' part may have "." in it, or may be empty for unqualified names.
--- The 'JName.base' part will be a simple 'String' for the last component.
data JName = !JName {qual :: String, base :: String}

instance Show JName where
    show (JName "" x) = x
    show (JName p  x) = p ++ "." ++ x

instance Eq   JName where
    ja == jb = show ja == show jb
    hashCode ja = hashCode ja.show




{--
    Given a 'JName' and a member name, returns the 'JName' of the member.
 -}
memberOf (JName "" b) c = JName b c
memberOf (JName a  b) c = JName (a++"."++b) c


